package demo3;

import java.io.*;
import java.util.Scanner;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: 33013
 * Date: 2023-08-02
 * Time: 10:14
 */
public class Test {
    public static void main(String[] args) throws IOException, InterruptedException {
//        Callable<Integer> callable = new Callable<Integer>() {
//            @Override
//            public Integer call() throws Exception {
//                return 3;
//            }
//        };
//        FutureTask futureTask = new FutureTask<>(callable);
//        Thread thread = new Thread(futureTask);
//        thread.start();
//        File file = new File("d:/test.txt");
//        //file.createNewFile();
//        file.delete();
//
//        System.out.println(file.getParent());
//        System.out.println(file.getName());
//        System.out.println(file.getCanonicalFile());
//        try(Reader reader = new FileReader("d:/text.txt");){
//            while (true){
//                char[] arr = new char[1];
//                int n = reader.read(arr);
//                if (n ==-1){
//                    break;
//                }
//                System.out.print(arr[0] + " ");
//            }
//        }
//        InputStream intputStream = new FileInputStream("d:/text.txt");
//        Scanner scanner = new Scanner(intputStream);
//        OutputStream outputStream = new FileOutputStream("d:/text.txt");
//        PrintWriter printWriter = new PrintWriter(outputStream);
//        printWriter.println(54);
//        outputStream.close();
        Thread thread = new Thread(() -> {
            while (Thread.currentThread().isInterrupted()){
                System.out.println("hello world");
            }
        });
        thread.start();
        //Thread.sleep(3000);
        thread.interrupt();
    }
}
